#include <iostream>
using namespace std;

int GetMonthDay (int year , int month)
{

    int arr [13] = { -1 , 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31} ;

    if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
    {

        return 29 ;

    }

    return arr [month] ;

}

int main() 
{

    int _month = 1 , count = 0 ;

    int year , month , day ;

    cin >> year >> month >> day ;

    while (_month < month)
    {

        count += GetMonthDay(year , _month) ;

        _month++ ;

    }

    count += day ;

    cout << count << endl ;

    return 0 ;

}
// 64 位输出请用 printf("%lld")